//
//  PKReadDetailTableViewCell.m
//  PianKe
//
//  Created by lanou on 15/10/13.
//  Copyright (c) 2015年 李伟伟. All rights reserved.
//

#import "PKReadDetailTableViewCell.h"
#import<UIImageView+WebCache.h>
@implementation PKReadDetailTableViewCell




-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WITDTH-20, 40)];
        _titleLabel.numberOfLines = 2;
        _coverimgView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 40, SCREEN_WITDTH/2-10, (SCREEN_WITDTH/2-10)/2) ];
//        _coverimgView.contentMode = UIViewContentModeScaleAspectFit;
//        _coverimgView.layer.masksToBounds = YES;
        _contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WITDTH/2 + 2, 40, SCREEN_WITDTH/2-20, (SCREEN_WITDTH/2-10)/2)];
        _contentLabel.numberOfLines = 3;
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_coverimgView];
        [self.contentView addSubview:_contentLabel];
        
    }
    return self;
}

-(void)configureCell:(PKReadDetailViewModel *)model
{
    _titleLabel.text = model.title;
    [_coverimgView sd_setImageWithURL:[NSURL URLWithString:model.coverimg]];
    _contentLabel.text = model.content;
}








/*****************************未启用的自适应高度****************************/


+(CGFloat)heightForTitleLabel:(NSString *)titleString
{
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:18] forKey:NSFontAttributeName];
    CGRect bounds = [titleString boundingRectWithSize:CGSizeMake(SCREEN_WITDTH-20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return bounds.size.height;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
